﻿<UserControl x:Class="SilverlightCoverage.CodeDisplay"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"  
    xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"    
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    xmlns:prim="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"
    xmlns:local="clr-namespace:SilverlightCoverage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    >
    <UserControl.Resources>
        <Style TargetType="prim:DataGridColumnHeader" x:Name="dthFull">            
            <Setter Property="Foreground" Value="White" />
            <Setter Property="FontSize" Value="11" />
            <Setter Property="FontFamily" Value="Arial"></Setter>
            <Setter Property="FontWeight" Value="Bold" />
            <Setter Property="IsTabStop" Value="False" />
            <Setter Property="SeparatorBrush" Value="White" />
            <Setter Property="Padding" Value="4,4,5,4" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="prim:DataGridColumnHeader">
                        <Grid Name="Root" HorizontalAlignment="Center">
                            <vsm:VisualStateManager.VisualStateGroups>
                                <vsm:VisualStateGroup x:Name="CommonStates">
                                    <vsm:VisualStateGroup.Transitions>
                                        <vsm:VisualTransition GeneratedDuration="00:00:0.1" />
                                    </vsm:VisualStateGroup.Transitions>
                                    <vsm:VisualState x:Name="Normal" />
                                </vsm:VisualStateGroup>
                                <vsm:VisualStateGroup x:Name="SortStates">
                                    <vsm:VisualStateGroup.Transitions>
                                        <vsm:VisualTransition GeneratedDuration="00:00:0.1" />
                                    </vsm:VisualStateGroup.Transitions>
                                    <vsm:VisualState x:Name="Unsorted" />
                                    <vsm:VisualState x:Name="SortAscending">
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="SortIcon" Storyboard.TargetProperty="Opacity" Duration="0" To="1.0"/>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="SortDescending">
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="SortIcon" Storyboard.TargetProperty="Opacity" Duration="0" To="1.0"/>
                                            <DoubleAnimation Storyboard.TargetName="SortIconTransform" Storyboard.TargetProperty="ScaleY" Duration="0" To="-.9"/>
                                        </Storyboard>
                                    </vsm:VisualState>
                                </vsm:VisualStateGroup>
                            </vsm:VisualStateManager.VisualStateGroups>

                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" />
                                <RowDefinition Height="*" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>

                            <Rectangle x:Name="BackgroundRectangle" Stretch="Fill" Fill="Transparent" Grid.ColumnSpan="2" Grid.RowSpan="2"/>

                            <Rectangle x:Name="BackgroundGradient" Stretch="Fill" Grid.ColumnSpan="2" Grid.RowSpan="2" Height="25" HorizontalAlignment="Center">                               
                                <Rectangle.Fill>
                                    <SolidColorBrush Color="#ababab"></SolidColorBrush>
                                </Rectangle.Fill>
                            </Rectangle>
                            <ContentPresenter
                        Grid.RowSpan="2"
                        Content="{TemplateBinding Content}"
                        Cursor="{TemplateBinding Cursor}"
                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"                        
                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}"        
                        Margin="{TemplateBinding Padding}"/>

                            <Rectangle Name="VerticalSeparator" Grid.RowSpan="2" Grid.Column="2" VerticalAlignment="Stretch" Fill="Transparent" Visibility="{TemplateBinding SeparatorVisibility}"/>

                            <Path Grid.RowSpan="2" Name="SortIcon" Fill="GhostWhite" Stroke="GhostWhite" RenderTransformOrigin=".5,.5" HorizontalAlignment="Left" VerticalAlignment="Center" Opacity="0" Grid.Column="1" Stretch="Uniform" Width="8" Data="F1 M -5.215,6.099L 5.215,6.099L 0,0L -5.215,6.099 Z ">
                                <Path.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform x:Name="SortIconTransform" ScaleX="1.15" ScaleY="1.15" />
                                    </TransformGroup>
                                </Path.RenderTransform>
                            </Path>

                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <local:Converter x:Key="convertit"></local:Converter>
        <local:CovPercentConverter x:Key="CoverageConverter"></local:CovPercentConverter>
        <local:CovPercentStringConverter x:Key="CovStringConverter"></local:CovPercentStringConverter>
        <local:CovPercentColorConverter x:Key="CovColorConverter"></local:CovPercentColorConverter>
        <local:MethodNameStripConverter x:Key="MthdNameConverter"></local:MethodNameStripConverter>
        
        <DataTemplate x:Name="dtemp">
            <StackPanel Orientation="Horizontal">
                <Border Background="{Binding Path=CovStatus,Converter={StaticResource convertit}}">
                    <TextBlock Text="{Binding LineNumber}" ></TextBlock>
                </Border>
                <Border Background="{Binding Path=CovStatus,Converter={StaticResource convertit}}">
                    <TextBlock Text="{Binding CodeString}" ></TextBlock>
                </Border>
            </StackPanel>
        </DataTemplate>

    </UserControl.Resources>
    <StackPanel x:Name="LayoutRoot" Orientation="Vertical">        
             <Border x:Name="dgBorder" ScrollViewer.VerticalScrollBarVisibility="Auto" Width="945" Margin="-30,0,0,0">
        <data:DataGrid x:Name="gridMethodNames" Width="920" AutoGenerateColumns="False" RowBackground="#eeeeee" AlternatingRowBackground="GhostWhite" GridLinesVisibility="Vertical" HeadersVisibility="Column" Background="#ababab" ColumnHeaderStyle="{StaticResource dthFull}" RowHeight="18.5" VerticalGridLinesBrush="White" FontFamily="Arial" FontSize="10.666" Margin="-25,0,0,0">
            <data:DataGrid.Columns>
                    <data:DataGridTemplateColumn Width="550" Header="Method Name" SortMemberPath="Methodname">
                        <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>                               
                             <HyperlinkButton x:Name="hyperMethods" Click="hyperMethods_Click" Foreground="Black"  Margin="15,0,0,0">
                                <TextBlock x:Name="txtHyper" Text="{Binding Path=Methodname,Converter={StaticResource MthdNameConverter}}" TextWrapping="Wrap" Width="550" VerticalAlignment="Center"  Margin="15,0,0,0"></TextBlock>
                            </HyperlinkButton>                           
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>
                <data:DataGridTemplateColumn Width="170" Header="Total Coverage" SortMemberPath="CovPercentage">

                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Border x:Name="brdCov">
                                <Grid HorizontalAlignment="Right">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="40"/>
                                        <ColumnDefinition Width="130" />
                                    </Grid.ColumnDefinitions> 
                                    <StackPanel Orientation="Horizontal" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center">
                                        <Border x:Name="brdCovPercentage" Background="{Binding Path=CovPercentage,Converter={StaticResource CovColorConverter}}" Height="15" HorizontalAlignment="Right" Grid.Column="0" Margin="5,0,0,0">
                                        <TextBlock x:Name="txtBlkCov" Text="{Binding Path=CovPercentage,Converter={StaticResource CovStringConverter}}" Grid.Column="0" HorizontalAlignment="Right"></TextBlock>
                                            </Border>
                                    </StackPanel>                                    
                                    <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
                                        <Border Background="#7CFC00" Width="{Binding CovPercentage}" Height="15">
                                            <TextBlock x:Name="txtBlkMajor"></TextBlock>
                                        </Border>
                                        <Border Background="#FF4500" Width="{Binding Path=CovPercentage,Converter={StaticResource CoverageConverter}}" Height="15">
                                            <TextBlock x:Name="txtBlkMinor"></TextBlock>
                                        </Border>
                                    </StackPanel>
                                </Grid>

                            </Border>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>
                <data:DataGridTemplateColumn Width="90" Header="Line Number" SortMemberPath="LineNumber">

                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding LineNumber}" HorizontalAlignment="Right" Margin="5,0,30,0" VerticalAlignment="Center"></TextBlock>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>
                <data:DataGridTemplateColumn Width="90" Header="Total Lines" SortMemberPath="TotalLines">

                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding TotalLines}" HorizontalAlignment="Right" Margin="5,0,30,0" VerticalAlignment="Center"></TextBlock>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>
            </data:DataGrid.Columns>
        </data:DataGrid>
        </Border>        
        <controls:TabControl x:Name="srcContainer" Width="880" Height="450" Margin="0,10,0,0" ScrollViewer.VerticalScrollBarVisibility="Visible" FontFamily="Arial" FontSize="10.666" Foreground="Black"></controls:TabControl>
    </StackPanel>
</UserControl>
